﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Treely.Data.Repositories
{
    public abstract class DisposableRepository : IDisposable
    {
        protected ApplicationDbContext db;

        protected DisposableRepository(ApplicationDbContext db)
        {
            this.db = db;
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        public void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
        }

        public void SaveChanges()
        {
            db.SaveChanges();
        }
    }
}